library(survey)
library(dplyr)
library(stargazer)
library(performance)

## Create weighted survey design object
w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df
  )

## creating Model for Table 2.5 
# model: multivariate model based on demographics, logit specification, DV: Q16_d
tab2.5_mod <- svyglm(Q16_d ~ factor(P_BRANCH) + dem + rep + ideo3 + 
                       male + white + black + hispanic + asian + 
                       income5 + EDUC5 + unemployed + married + 
                       silent + boomer + genx + millen + 
                       activeduty + vet + social + family + 
                       midwest + south + west + 
                       catholic + christian + norelig +
                       city + rural + 
                       A2 + A3 + A4 + A5 + A6 + A7 + A8,
                   family = binomial(link = "logit"),
                   design = w2_design)
summary(tab2.5_mod)

stargazer(tab2.5_mod)
check_collinearity(tab2.5_mod)
